package com.jiyici.model;

import java.util.ArrayList;

import org.json.JSONException;
import org.json.JSONObject;

import jiyici.Constant.ModelColumn;
import android.content.ContentValues;
import android.database.Cursor;

public class Record extends ClientBaseModel {

    private static final long serialVersionUID = 234433337610149366L;

    public long itemId;

    public long recordTime;
    
    public ArrayList<RecordParam> paramList = new ArrayList<RecordParam>();
    
    @Override
    public ContentValues toContentValues() {
        ContentValues values = super.toContentValues();
        values.put(ModelColumn.RECORD_ITEM_ID, itemId);
        values.put(ModelColumn.RECORD_RECORD_TIME, recordTime);
        return values;
    }
    
    @Override
    public void fromCursor(Cursor c) {
        super.fromCursor(c);
        itemId = c.getLong(c.getColumnIndex(ModelColumn.RECORD_ITEM_ID));
        recordTime = c.getLong(c.getColumnIndex(ModelColumn.RECORD_RECORD_TIME));
    }
    
    @Override
    public void fromJson(JSONObject json) throws JSONException {
        super.fromJson(json);
        itemId = json.getLong(ModelColumn.RECORD_ITEM_ID);
        recordTime = json.getLong(ModelColumn.RECORD_RECORD_TIME);
    }
    
    @Override
    public JSONObject toJson() throws JSONException {
        JSONObject json = super.toJson();
        json.put(ModelColumn.RECORD_ITEM_ID, itemId);
        json.put(ModelColumn.RECORD_RECORD_TIME, recordTime);
        return json;
    }

    @Override
    public String toString() {
        return "Record [id=" + id + ", userId=" + userId + ", lastmodified=" + lastmodified + ", deleted=" + deleted
                + ", dirty=" + dirty + ", itemId=" + itemId + ", recordTime=" + recordTime + "]";
    }
}
